package cii_lib;

public class CCII_TABLE_INDEX {
  private CCII_CONFIG_TABLE tab[];
  private int _index;
  private int _cid;
  public CCII_TABLE_INDEX(CCII_CONFIG_TABLE src[]) {tab=src; _index=0; _cid=-1;}
  public CCII_TABLE_INDEX(CCII_CONFIG_TABLE src[], int index) {tab=src; _index=index; _cid=readItCompId();}
  public CCII_TABLE_INDEX(CCII_TABLE_INDEX itab, int inc) {
    tab=itab.tab;
    _index=itab._index;
    _cid=itab._cid;
    if(itab.GetItem().Type==CIIlib.TABLE_TYPE.COMP)  _cid=++itab._cid;
    itab._index+=inc; //FIXME  o co chodzi ?
  }
  public int  GetIndex() {return(_index);}
  public int  GetCompID() {return(_cid);}
  public CCII_CONFIG_TABLE GetItem() {return(tab[_index]);}
  public CCII_CONFIG_TABLE GetItem(int inc) {return(tab[_index+inc]);}
  public CCII_CONFIG_TABLE[] getItems() {return tab;}

  /**
   * Add to determine table size
   * @author pdrabik
   * @return table size
   */
public final int getTableSize() { return tab.length; }
public final int readItCompId() { return tab[_index].CompID; }
@Override
public String toString() {
//	return GetItem().toString();
	return ""+ GetItem().CompID+" "+ GetItem().Name;
}
}
